<template>
  <z-modal
    :width="800"
    v-bind="modalOption"
    :okText="false"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model layout="horizontal" labelAlign="right" ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol" :model="form" :rules="validatorRules">
        <a-form-model-item label="SSH 名称" prop="name">
          <a-input placeholder="请输入SSH 名称" v-model.trim="form.name" :disabled="disableSubmit"/>
        </a-form-model-item>
        <a-form-model-item label="Host" prop="host">
          <a-input-group compact prop="host">
            <a-input style="width: 70%" v-model="form.host" placeholder="主机 Host" :disabled="disableSubmit"/>
            <a-input-number style="width: 30%" v-model="form.port" :min="1" placeholder="端口号" :defaultValue=22 :disabled="disableSubmit"/>
          </a-input-group>
        </a-form-model-item>
        <a-form-model-item label="用户名" prop="user">
          <a-input placeholder="请输入用户名" v-model.trim="form.user" :disabled="disableSubmit"/>
        </a-form-model-item>
        <a-form-model-item label="密码" prop="password">
          <a-input-password placeholder="请输入密码" v-model.trim="form.password" :disabled="disableSubmit"/>
        </a-form-model-item>
        <a-form-model-item label="超时时间(s)" prop="timeout">
          <a-input-number v-model="form.timeout" :min="1" placeholder="单位秒,最小值 1 秒" style="width: 100%" defaultValue=60 />
        </a-form-model-item>
        <a-form-model-item label="编码格式" prop="charset">
          <a-input placeholder="请输入编码格式" v-model.trim="form.charset" :disabled="disableSubmit"/>
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </z-modal>
</template>

<script>
import ModalFormMixin from '@/mixins/ModalFormMixin'
import ZDictSelectTag from '@/components/dict/ZDictSelectTag'
export default {
  name: 'SshModal',
  mixins: [ModalFormMixin],
  components: {
    ZDictSelectTag
  },
  data() {
    return {
      validatorRules: {
        host: [
          { required: true, message: '请输入目标IP!' }
        ],
      },
      url: {
        add: '/monitor-ssh/add',
        edit: '/monitor-ssh/edit'
      }
    }
  },
  methods: {
    addAfter() {
    }
  }
}
</script>
